function init(){
    //email检验置空
    document.getElementById("email").addEventListener("focus",()=>{
        document.querySelector(".email_error_msg").innerHTML="";
        document.querySelector(".email_error_img").classList.remove("errorImg");
        document.querySelector(".email_error_msg").classList.remove("errorMessage");
        document.querySelector(".email_error_msg").classList.remove("okMessage");
        document.querySelector(".email_error_img").classList.remove("okImg");
    },false);
    //email检验
    document.getElementById("email").addEventListener("blur",()=>{
        let regExp=/^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/;
        if(!regExp.test(document.getElementById("email").value)){
            document.querySelector(".email_error_msg").innerHTML="邮箱格式不正确！";
            document.querySelector(".email_error_msg").classList.add("errorMessage");
            document.querySelector(".email_error_img").classList.add("errorImg");
        }else{
            document.querySelector(".email_error_msg").innerHTML="邮箱格式符合要求！";
            document.querySelector(".email_error_msg").classList.add("okMessage");
            document.querySelector(".email_error_img").classList.add("okImg"); 
        }
    },false);
    document.getElementById("userName").addEventListener("focus",()=>{
        document.querySelector(".userName_error_msg").innerHTML="";
        document.querySelector(".userName_error_img").classList.remove("errorImg");
        document.querySelector(".userName_error_msg").classList.remove("errorMessage");
        document.querySelector(".userName_error_msg").classList.remove("okMessage");
        document.querySelector(".userName_error_img").classList.remove("okImg");
    },false);
    document.getElementById("userName").addEventListener("blur",()=>{
        let regExp= /^[a-zA-Z0-9_-]{4,16}$/;
        if(!regExp.test(document.getElementById("userName").value)){
            document.querySelector(".userName_error_msg").innerHTML="用户名格式不正确！";
            document.querySelector(".userName_error_msg").classList.add("errorMessage");
            document.querySelector(".userName_error_img").classList.add("errorImg");
        }else{
            document.querySelector(".userName_error_msg").innerHTML="用户名格式符合要求！";
            document.querySelector(".userName_error_msg").classList.add("okMessage");
            document.querySelector(".userName_error_img").classList.add("okImg"); 
        }
    },false);  
    document.getElementById("password").addEventListener("focus",()=>{
        document.querySelector(".password_error_msg").innerHTML="";
        document.querySelector(".password_error_img").classList.remove("errorImg");
        document.querySelector(".password_error_msg").classList.remove("errorMessage");
        document.querySelector(".password_error_msg").classList.remove("okMessage");
        document.querySelector(".password_error_img").classList.remove("okImg");
    },false);
    document.getElementById("password").addEventListener("blur",()=>{
        let regExp= /^\w{8,20}$/;
        if(!regExp.test(document.getElementById("password").value)){
            document.querySelector(".password_error_msg").innerHTML="密码格式不正确！";
            document.querySelector(".password_error_msg").classList.add("errorMessage");
            document.querySelector(".password_error_img").classList.add("errorImg");
        }else{
            document.querySelector(".password_error_msg").innerHTML="密码格式符合要求！";
            document.querySelector(".password_error_msg").classList.add("okMessage");
            document.querySelector(".password_error_img").classList.add("okImg"); 
        }
    },false);    
    document.getElementById("password").addEventListener("focus",()=>{
        document.querySelector(".password_error_msg").innerHTML="";
        document.querySelector(".password_error_img").classList.remove("errorImg");
        document.querySelector(".password_error_msg").classList.remove("errorMessage");
        document.querySelector(".password_error_msg").classList.remove("okMessage");
        document.querySelector(".password_error_img").classList.remove("okImg");
    },false);
    document.getElementById("password").addEventListener("blur",()=>{
        let regExp= /^\w{8,20}$/;
        if(!regExp.test(document.getElementById("password").value)){
            document.querySelector(".password_error_msg").innerHTML="密码格式不正确！";
            document.querySelector(".password_error_msg").classList.add("errorMessage");
            document.querySelector(".password_error_img").classList.add("errorImg");
        }else{
            document.querySelector(".password_error_msg").innerHTML="密码格式符合要求！";
            document.querySelector(".password_error_msg").classList.add("okMessage");
            document.querySelector(".password_error_img").classList.add("okImg"); 
        }
    },false); 
    document.getElementById("phone").addEventListener("focus",()=>{
        document.querySelector(".phone_error_msg").innerHTML="";
        document.querySelector(".phone_error_img").classList.remove("errorImg");
        document.querySelector(".phone_error_msg").classList.remove("errorMessage");
        document.querySelector(".phone_error_msg").classList.remove("okMessage");
        document.querySelector(".phone_error_img").classList.remove("okImg");
    },false);
    document.getElementById("phone").addEventListener("blur",()=>{
        let regExp=/^1[34578][0-9]{9}$/;
        if(!regExp.test(document.getElementById("phone").value)){
            document.querySelector(".phone_error_msg").innerHTML="手机号码格式不正确！";
            document.querySelector(".phone_error_msg").classList.add("errorMessage");
            document.querySelector(".phone_error_img").classList.add("errorImg");
        }else{
            document.querySelector(".phone_error_msg").innerHTML="手机号码格式符合要求！";
            document.querySelector(".phone_error_msg").classList.add("okMessage");
            document.querySelector(".phone_error_img").classList.add("okImg"); 
        }
    },false); 
document.getElementById("nickName").addEventListener("focus",()=>{
    document.querySelector(".nickName_error_msg").innerHTML="";
    document.querySelector(".nickName_error_img").classList.remove("errorImg");
    document.querySelector(".nickName_error_msg").classList.remove("errorMessage");
    document.querySelector(".nickName_error_msg").classList.remove("okMessage");
    document.querySelector(".nickName_error_img").classList.remove("okImg");
},false);
document.getElementById("nickName").addEventListener("blur",()=>{
    var nickName = document.getElementById("nickName").value;
    if(nickName.length==0){
        document.querySelector(".nickName_error_msg").innerHTML="昵称不为空";
        document.querySelector(".nickName_error_msg").classList.add("errorMessage");
        document.querySelector(".nickName_error_img").classList.add("errorImg");
    }else{
    document.querySelector(".nickName_error_msg").innerHTML="昵称符合要求！";
    document.querySelector(".nickName_error_msg").classList.add("okMessage");
    document.querySelector(".nickName_error_img").classList.add("okImg"); 
} 
},false); 
document.getElementById("rePassword").addEventListener("focus",()=>{
    document.querySelector(".userName_error_msg").innerHTML="";
    document.querySelector(".userName_error_img").classList.remove("errorImg");
    document.querySelector(".userName_error_msg").classList.remove("errorMessage");
    document.querySelector(".userName_error_msg").classList.remove("okMessage");
    document.querySelector(".userName_error_img").classList.remove("okImg");
},false);
document.getElementById("rePassword").addEventListener("blur",()=>{
    console.log(document.getElementById("password").value);
    console.log(document.getElementById("rePassword").value);
        if(document.getElementById("password").value!=document.getElementById("rePassword").value){
        document.querySelector(".rePassword_error_msg").innerHTML="与原密码不同";
        document.querySelector(".rePassword_error_msg").classList.add("errorMessage");
        document.querySelector(".rePassword_error_img").classList.add("errorImg");
    }else{
    document.querySelector(".rePassword_error_msg").innerHTML="密码相同";
    document.querySelector(".rePassword_error_msg").classList.add("okMessage");
    document.querySelector(".rePassword_error_img").classList.add("okImg"); 
    }
},false); 
}
window.addEventListener("load",init,false); 


